import type {
  GetCodeData,
  GetCodeParams,
  LoginCodeParams,
  LoginData,
  LoginPasswordParams,
  UserData,
} from "@/types/user"
import { request } from "@/utils/http"

// 1. 获取短信验证码 -> 测试 -> 真实项目会发送到用户手机上
// login登录register注册changeMobile更换手机号forgetPassword找回密码,bindMobile绑定三方登录，区分验证码
// 发送验证码
export const getCodeApi = (params: GetCodeParams) => {
  return request.get<null, GetCodeData>("/code", { params })
}

// 2. 手机验证码登录
export const loginByMobileApi = (data: LoginCodeParams) => {
  return request.post<null, LoginData>("/login", data)
}

// 3. 密码登录
export const loginByPasswordApi = (data: LoginPasswordParams) => {
  return request.post<null, LoginData>("/login/password", data)
}

// 4. 我的-获取个人用户信息
export const userInfoApi = () => {
  return request.get<null, UserData>("/patient/myUser")
}
